<div class="simple">
<?php echo CHtml::activeLabelEx($model, 'out_permit'); ?>
<?php $this->widget('CAutoComplete',
          array(
                         //name of the html field that will be generated
             'model'=>$model,
             'attribute'=>'out_permit',
                         //replace controller/action with real ids
             'url'=>array('enquiry/ExportPermit'),
             'max'=>10, //specifies the max number of items to display

                         //specifies the number of chars that must be entered
                         //before autocomplete initiates a lookup
             'minChars'=>3,
             'delay'=>200, //number of milliseconds before lookup occurs
             'matchCase'=>false, //match case when performing a lookup?

                         //any additional html attributes that go inside of
                         //the input field can be defined here
             'htmlOptions'=>array('size'=>'30'),
             'methodChain'=>'.result(function(event,item){ if(item[1]!=0){ $("#subcert_id").val(item[1]);Load_Permit_Infos(item[1]); } else { $("#subcert_id").val("0"); New_Permit(item[2]); }})',

             ));
         CHtml::activeHiddenField($model, 'id', array('value'=>'0'));
         $script = 'function New_Permit(permit) { $("input:text[id=subcert_out_permit]").val(permit);permit_dialog_form_open();}';
         $script .= "function Load_Permit_Infos(permit){ $.ajax({'url':'".CHtml::normalizeUrl(array('/subcert/show'))."','type':'GET','data':'id=1','cache':false,'success':function(html){jQuery('#subcert_display').html(html)}});}";
Yii::app()->getClientScript()->registerScript('Yii.NewPermit.form',$script,CClientScript::POS_READY);
?>
</div>

<hr />

<div id="subcert_display">
    <?php if(empty($model->id)):  ?>
        No export information.
    <?php endif; ?>
</div>